home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
cmln0186.arc
/
ARTINT1.LTG
next >
Wrap
Text File
|
1986-12-20
|
768b
|
20 lines
Listing 1
Pattern Matcher in Prolog
[1] match(X,X).
[2] match(?,_).
[3] match(*,_).
[4] match([* | PT], E) :- append(_,ET,E), match(PT,ET).
[5] match([PH | PT],[EH | ET]) :- match(PH,EH), match(PT,ET).
In case your Prolog doesn't include the append predicate, here's
an implementation; it asserts that its third argument is a list
that is the result of appending its first two arguments.
append([],L,L).
append([X|L1],L2,[X|L3]) :- append(L1,L2,L3).